package initialize

import (
	"fmt"
	"gopkg.in/mgo.v2"
)

func MongoDB() *mgo.Database {
	session, err := mgo.Dial("mongodb://testuser:123456@localhost:27017/?authSource=test")

	if err != nil {
		fmt.Errorf("connect to MongoDB fail : %s", err.Error())
		return nil
	}

	db := session.DB("test")
	fmt.Println("Connect to MongoDB succeed !!! ")

	return db
}
